
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>Service基类 · Diboot基础框架</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-theme-vuejs-2/vue.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="Mapper基类与SQL.html" />
    
    
    <link rel="prev" href="Model基类.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                



<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    介绍
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../开始使用.html">
            
                <a href="../开始使用.html">
            
                    
                    开始使用
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../开始使用/搭建环境.html">
            
                <a href="../开始使用/搭建环境.html">
            
                    
                    搭建环境
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../开始使用/使用framework.html">
            
                <a href="../开始使用/使用framework.html">
            
                    
                    使用diboot-framework
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../CRUD通用封装.html">
            
                <a href="../CRUD通用封装.html">
            
                    
                    CRUD通用封装
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="Model基类.html">
            
                <a href="Model基类.html">
            
                    
                    Model基类
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.3.2" data-path="Service基类.html">
            
                <a href="Service基类.html">
            
                    
                    Service基类
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="Mapper基类与SQL.html">
            
                <a href="Mapper基类与SQL.html">
            
                    
                    Mapper基类与SQL
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../MVC通用封装.html">
            
                <a href="../MVC通用封装.html">
            
                    
                    MVC通用封装
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../MVC通用封装/Controller基类.html">
            
                <a href="../MVC通用封装/Controller基类.html">
            
                    
                    Controller基类
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../MVC通用封装/CrudController基类.html">
            
                <a href="../MVC通用封装/CrudController基类.html">
            
                    
                    CrudController基类
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../MVC通用封装/CrudRestController基类.html">
            
                <a href="../MVC通用封装/CrudRestController基类.html">
            
                    
                    CrudRestController基类
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../认证与安全.html">
            
                <a href="../认证与安全.html">
            
                    
                    认证与安全
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../认证与安全/jwt授权.html">
            
                <a href="../认证与安全/jwt授权.html">
            
                    
                    JWT认证
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../认证与安全/CSRF防护.html">
            
                <a href="../认证与安全/CSRF防护.html">
            
                    
                    CSRF防护
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../认证与安全/XSS防护.html">
            
                <a href="../认证与安全/XSS防护.html">
            
                    
                    XSS防护
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../系统参数配置.html">
            
                <a href="../系统参数配置.html">
            
                    
                    系统参数配置
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../系统参数配置/配置文件.html">
            
                <a href="../系统参数配置/配置文件.html">
            
                    
                    参数配置在文件中
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../系统参数配置/数据库表.html">
            
                <a href="../系统参数配置/数据库表.html">
            
                    
                    参数配置在数据库表中
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../系统日志记录.html">
            
                <a href="../系统日志记录.html">
            
                    
                    系统日志记录
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../系统日志记录/操作日志.html">
            
                <a href="../系统日志记录/操作日志.html">
            
                    
                    操作日志
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="../系统日志记录/跟踪日志.html">
            
                <a href="../系统日志记录/跟踪日志.html">
            
                    
                    跟踪日志
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../常用工具类.html">
            
                <a href="../常用工具类.html">
            
                    
                    常用工具类
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.8.1" data-path="../常用工具类/D.html">
            
                <a href="../常用工具类/D.html">
            
                    
                    日期时间类D
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.2" data-path="../常用工具类/S.html">
            
                <a href="../常用工具类/S.html">
            
                    
                    字符串类S
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.3" data-path="../常用工具类/V.html">
            
                <a href="../常用工具类/V.html">
            
                    
                    数据校验类V
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.4" data-path="../常用工具类/BeanUtils.html">
            
                <a href="../常用工具类/BeanUtils.html">
            
                    
                    Bean工具类
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.5" data-path="../常用工具类/JSON.html">
            
                <a href="../常用工具类/JSON.html">
            
                    
                    Json工具类
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.6" data-path="../常用工具类/Encryptor.html">
            
                <a href="../常用工具类/Encryptor.html">
            
                    
                    加解密类
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.7" data-path="../常用工具类/IdGenerator.html">
            
                <a href="../常用工具类/IdGenerator.html">
            
                    
                    ID生成器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.8" data-path="../常用工具类/Query.html">
            
                <a href="../常用工具类/Query.html">
            
                    
                    条件构造器
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../通用基础模型.html">
            
                <a href="../通用基础模型.html">
            
                    
                    通用基础模型
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.9.1" data-path="../通用基础模型/用户角色权限.html">
            
                <a href="../通用基础模型/用户角色权限.html">
            
                    
                    用户角色权限
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.2" data-path="../通用基础模型/元数据.html">
            
                <a href="../通用基础模型/元数据.html">
            
                    
                    元数据
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.3" data-path="../通用基础模型/文件.html">
            
                <a href="../通用基础模型/文件.html">
            
                    
                    文件
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>



                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                

                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >Service基类</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <div id="anchor-navigation-ex-navbar"><i class="fa fa-navicon"></i><ul><li><span class="title-icon "></span><a href="#service&#x57FA;&#x7C7B;"><b>1. </b>Service&#x57FA;&#x7C7B;</a></li><ul><li><span class="title-icon "></span><a href="#baseservicebaseserviceimpl&#x9ED8;&#x8BA4;&#x5B9E;&#x73B0;&#x7684;&#x63A5;&#x53E3;"><b>1.1. </b>BaseService(BaseServiceImpl)&#x9ED8;&#x8BA4;&#x5B9E;&#x73B0;&#x7684;&#x63A5;&#x53E3;</a></li><ul><li><span class="title-icon "></span><a href="#&#x83B7;&#x53D6;model"><b>1.1.1. </b>&#x83B7;&#x53D6;Model</a></li><li><span class="title-icon "></span><a href="#&#x521B;&#x5EFA;&#x6279;&#x91CF;&#x521B;&#x5EFA;model"><b>1.1.2. </b>&#x521B;&#x5EFA;(&#x6279;&#x91CF;&#x521B;&#x5EFA;)Model</a></li><li><span class="title-icon "></span><a href="#&#x66F4;&#x65B0;model"><b>1.1.3. </b>&#x66F4;&#x65B0;Model</a></li><li><span class="title-icon "></span><a href="#&#x5220;&#x9664;&#x6570;&#x636E;"><b>1.1.4. </b>&#x5220;&#x9664;&#x6570;&#x636E;</a></li><li><span class="title-icon "></span><a href="#&#x67E5;&#x8BE2;&#x6570;&#x636E;"><b>1.1.5. </b>&#x67E5;&#x8BE2;&#x6570;&#x636E;</a></li></ul><li><span class="title-icon "></span><a href="#&#x65B0;&#x5EFA;&#x4E00;&#x4E2A;crud&#x7684;service"><b>1.2. </b>&#x65B0;&#x5EFA;&#x4E00;&#x4E2A;CRUD&#x7684;Service</a></li></ul></ul></div><a href="#service&#x57FA;&#x7C7B;" id="anchorNavigationExGoTop"><i class="fa fa-arrow-up"></i></a><h1 id="service&#x57FA;&#x7C7B;"><a name="service&#x57FA;&#x7C7B;" class="anchor-navigation-ex-anchor" href="#service&#x57FA;&#x7C7B;"><i class="fa fa-link" aria-hidden="true"></i></a>1. Service&#x57FA;&#x7C7B;</h1>
<h2 id="baseservicebaseserviceimpl&#x9ED8;&#x8BA4;&#x5B9E;&#x73B0;&#x7684;&#x63A5;&#x53E3;"><a name="baseservicebaseserviceimpl&#x9ED8;&#x8BA4;&#x5B9E;&#x73B0;&#x7684;&#x63A5;&#x53E3;" class="anchor-navigation-ex-anchor" href="#baseservicebaseserviceimpl&#x9ED8;&#x8BA4;&#x5B9E;&#x73B0;&#x7684;&#x63A5;&#x53E3;"><i class="fa fa-link" aria-hidden="true"></i></a>1.1. BaseService(BaseServiceImpl)&#x9ED8;&#x8BA4;&#x5B9E;&#x73B0;&#x7684;&#x63A5;&#x53E3;</h2>
<ul>
<li>Service&#x57FA;&#x7C7B;&#x63D0;&#x4F9B;&#x4E86;&#x5E38;&#x7528;CRUD&#x573A;&#x666F;&#x7684;Java&#x4EE3;&#x7801;&#x90E8;&#x5206;&#x5B9E;&#x73B0;&#x3002;
  &#x5728;&#x4F7F;&#x7528;&#x8FC7;&#x7A0B;&#x4E2D;&#xFF0C;&#x5982;&#x679C;&#x9ED8;&#x8BA4;&#x5B9E;&#x73B0;&#x53EF;&#x4EE5;&#x6EE1;&#x8DB3;&#x60A8;&#x7684;&#x9700;&#x8981;&#xFF0C;&#x90A3;&#x4E48;&#x5728;&#x60A8;&#x65B0;&#x589E;&#x7684;service&#x5B9E;&#x73B0;&#x4E2D;&#xFF0C;&#x65E0;&#x9700;&#x518D;&#x5199;&#x76F8;&#x5173;&#x5B9E;&#x73B0;&#x4EE3;&#x7801;&#xFF0C;
  &#x5426;&#x5219;&#x53EF;&#x4EE5;&#x91CD;&#x5199;&#x8986;&#x76D6;&#x76F8;&#x5173;&#x63A5;&#x53E3;&#x7684;&#x5B9E;&#x73B0;&#xFF0C;&#x6765;&#x5B9E;&#x73B0;&#x7279;&#x5B9A;&#x9700;&#x6C42;&#x3002;</li>
</ul>
<h3 id="&#x83B7;&#x53D6;model"><a name="&#x83B7;&#x53D6;model" class="anchor-navigation-ex-anchor" href="#&#x83B7;&#x53D6;model"><i class="fa fa-link" aria-hidden="true"></i></a>1.1.1. &#x83B7;&#x53D6;Model</h3>
<ul>
<li><t extends="" basemodel="">T getModel(Object pk);<ul>
<li>&#x6839;&#x636E;&#x4E3B;&#x952E;&#x83B7;&#x53D6;&#x5BF9;&#x5E94;&#x7684;&#x8BB0;&#x5F55;&#xFF0C;&#x5E76;&#x8FD4;&#x56DE;&#x8BE5;&#x6761;&#x8BB0;&#x5F55;&#x7684;model&#x5B9E;&#x4F53;</li>
</ul>
</t></li>
</ul>
<pre><code class="lang-java">    Metadata model = medatadaService.getModel(<span class="hljs-number">120L</span>);
</code></pre>
<h3 id="&#x521B;&#x5EFA;&#x6279;&#x91CF;&#x521B;&#x5EFA;model"><a name="&#x521B;&#x5EFA;&#x6279;&#x91CF;&#x521B;&#x5EFA;model" class="anchor-navigation-ex-anchor" href="#&#x521B;&#x5EFA;&#x6279;&#x91CF;&#x521B;&#x5EFA;model"><i class="fa fa-link" aria-hidden="true"></i></a>1.1.2. &#x521B;&#x5EFA;(&#x6279;&#x91CF;&#x521B;&#x5EFA;)Model</h3>
<ul>
<li>boolean createModel(BaseModel model);<ul>
<li>&#x521B;&#x5EFA;&#x5355;&#x6761;&#x8BB0;&#x5F55;&#xFF08;&#x975E;&#x6570;&#x636E;&#x5E93;&#x81EA;&#x589E;&#x4E3B;&#x952E;&#xFF0C;&#x521B;&#x5EFA;&#x524D;&#x4F1A;&#x5148;&#x751F;&#x6210;&#x4E3B;&#x952E;&#xFF09;</li>
</ul>
</li>
</ul>
<pre><code class="lang-java">    <span class="hljs-keyword">boolean</span> success = medatadaService.createModel(metadata);
</code></pre>
<ul>
<li><t extends="" basemodel=""> boolean batchCreateModels(List<t> modelList);<ul>
<li>&#x6279;&#x91CF;&#x521B;&#x5EFA;&#x591A;&#x6761;&#x8BB0;&#x5F55;&#xFF0C;&#x6570;&#x91CF;&#x8D85;100&#x6761;&#x4F1A;&#x5206;&#x6279;&#x6B21;&#x63D2;&#x5165;&#xFF08;100&#x6761;/&#x6279;&#x6B21;&#xFF09;&#x3002;&#xFF08;&#x975E;&#x6570;&#x636E;&#x5E93;&#x81EA;&#x589E;&#x4E3B;&#x952E;&#xFF0C;&#x521B;&#x5EFA;&#x524D;&#x4F1A;&#x5148;&#x751F;&#x6210;&#x4E3B;&#x952E;&#xFF09;</li>
</ul>
</t></t></li>
</ul>
<pre><code class="lang-java">    <span class="hljs-keyword">boolean</span> success = medatadaService.batchCreateModels(newMetadataList);
</code></pre>
<h3 id="&#x66F4;&#x65B0;model"><a name="&#x66F4;&#x65B0;model" class="anchor-navigation-ex-anchor" href="#&#x66F4;&#x65B0;model"><i class="fa fa-link" aria-hidden="true"></i></a>1.1.3. &#x66F4;&#x65B0;Model</h3>
<ul>
<li>boolean updateModel(BaseModel model, String... updateFields);<ul>
<li>&#x66F4;&#x65B0;&#x4E00;&#x6761;&#x6570;&#x636E;&#x8BB0;&#x5F55;</li>
<li>updateFields&#x662F;&#x4E00;&#x4E2A;&#x53D8;&#x53C2;&#xFF0C;&#x5982;&#x679C;&#x4F20;&#x5165;&#xFF0C;&#x8BE5;&#x63A5;&#x53E3;&#x5BF9;&#x5E94;&#x7684;update&#x8BED;&#x53E5;&#x53EA;&#x66F4;&#x65B0;&#x8BE5;&#x53D8;&#x91CF;&#x4E2D;&#x6307;&#x5B9A;&#x7684;&#x5B57;&#x6BB5;&#xFF0C;&#x5176;&#x4ED6;&#x5B57;&#x6BB5;&#x5C06;&#x4E0D;&#x66F4;&#x65B0;&#xFF0C;&#x907F;&#x514D;&#x810F;&#x5199;&#x3002;</li>
</ul>
</li>
</ul>
<pre><code class="lang-java">    <span class="hljs-comment">// &#x66F4;&#x65B0;&#x5168;&#x90E8;&#x5B57;&#x6BB5;</span>
    <span class="hljs-keyword">boolean</span> success = medatadaService.updateModel(metadata);
    <span class="hljs-comment">// &#x4EC5;&#x66F4;&#x65B0;itemValue&#x5B57;&#x6BB5;</span>
    <span class="hljs-keyword">boolean</span> success = medatadaService.updateModel(metadata, Metadata.F.itemValue);
</code></pre>
<ul>
<li>boolean createOrUpdateModel(BaseModel model);<ul>
<li>&#x521B;&#x5EFA;&#x6216;&#x66F4;&#x65B0;Model&#xFF08;model&#x4E3A;&#x65B0;&#x7684;&#x5BF9;&#x8C61;(isNew==true)&#x5219;&#x8C03;&#x7528;createModel&#x65B0;&#x5EFA;&#xFF0C;&#x5426;&#x5219;&#x8C03;&#x7528;updateModel&#x66F4;&#x65B0;&#xFF09;</li>
</ul>
</li>
</ul>
<pre><code class="lang-java">    <span class="hljs-keyword">boolean</span> success = medatadaService.createOrUpdateModel(metadata);
</code></pre>
<h3 id="&#x5220;&#x9664;&#x6570;&#x636E;"><a name="&#x5220;&#x9664;&#x6570;&#x636E;" class="anchor-navigation-ex-anchor" href="#&#x5220;&#x9664;&#x6570;&#x636E;"><i class="fa fa-link" aria-hidden="true"></i></a>1.1.4. &#x5220;&#x9664;&#x6570;&#x636E;</h3>
<ul>
<li>boolean deleteModel(Object pk);<ul>
<li>&#x6839;&#x636E;&#x4E3B;&#x952E;&#x5220;&#x9664;&#x4E00;&#x6761;&#x6570;&#x636E;&#x8BB0;&#x5F55;</li>
<li>&#x5728;&#x7CFB;&#x7EDF;&#x63D0;&#x4F9B;&#x7684;&#x9ED8;&#x8BA4;&#x5B9E;&#x73B0;&#x4E2D;&#xFF0C;&#x4E3A;&#x903B;&#x8F91;&#x5220;&#x9664;&#xFF0C;&#x5373;&#x5C06;active&#x5B57;&#x6BB5;&#x66F4;&#x65B0;&#x4E3A;0&#xFF0C;&#x6240;&#x6709;&#x67E5;&#x8BE2;&#x4E2D;&#x901A;&#x8FC7;active=1&#x6765;&#x7B5B;&#x9009;&#x6709;&#x6548;&#x6570;&#x636E;</li>
</ul>
</li>
</ul>
<pre><code class="lang-java">    <span class="hljs-keyword">boolean</span> success = medatadaService.deleteModel(<span class="hljs-number">120L</span>);
</code></pre>
<h3 id="&#x67E5;&#x8BE2;&#x6570;&#x636E;"><a name="&#x67E5;&#x8BE2;&#x6570;&#x636E;" class="anchor-navigation-ex-anchor" href="#&#x67E5;&#x8BE2;&#x6570;&#x636E;"><i class="fa fa-link" aria-hidden="true"></i></a>1.1.5. &#x67E5;&#x8BE2;&#x6570;&#x636E;</h3>
<ul>
<li>int getModelListCount(Map<string, object=""> criteria)<ul>
<li>&#x6839;&#x636E;&#x4F20;&#x5165;&#x7684;&#x6761;&#x4EF6;&#x8FD4;&#x56DE;&#x7B26;&#x5408;&#x6761;&#x4EF6;&#x7684;&#x8BB0;&#x5F55;&#x6570;(criteria&#x4E3A;null&#x5219;&#x8FD4;&#x56DE;&#x6240;&#x6709;&#x6709;&#x6548;&#x8BB0;&#x5F55;&#x6570;)</li>
</ul>
</string,></li>
</ul>
<pre><code class="lang-java">    Query query = <span class="hljs-keyword">new</span> Query();
    query.add(Metadata.F.parentId, <span class="hljs-number">0</span>);
    <span class="hljs-keyword">int</span> totalCount = medatadaService.getModelListCount(query.build());
</code></pre>
<ul>
<li><t extends="" basemodel=""> List<t> getModelList(Map<string, object=""> criteria, int... page)<ul>
<li>&#x6839;&#x636E;&#x6761;&#x4EF6;&#x4EE5;&#x53CA;&#x9875;&#x7801;&#xFF0C;&#x6765;&#x83B7;&#x53D6;&#x6570;&#x636E;&#x5217;&#x8868;</li>
<li>page&#x53C2;&#x6570;&#x4E3A;&#x53D8;&#x53C2;&#xFF0C;&#x4F20;&#x5165;&#x5219;&#x5206;&#x9875;&#xFF0C;&#x4E0D;&#x4F20;&#x5219;&#x8FD4;&#x56DE;&#x7B26;&#x5408;&#x6761;&#x4EF6;&#x7684;&#x6240;&#x6709;&#x8BB0;&#x5F55;</li>
</ul>
</string,></t></t></li>
</ul>
<pre><code class="lang-java">    Query query = <span class="hljs-keyword">new</span> Query();
    query.add(Metadata.F.parentId, <span class="hljs-number">0</span>);
    List&lt;Metadata&gt; modelList = medatadaService.getModelList(query.build()); <span class="hljs-comment">//&#x6240;&#x6709;</span>
    List&lt;Metadata&gt; modelList = medatadaService.getModelList(query.build(), <span class="hljs-number">1</span>); <span class="hljs-comment">//&#x7B2C;&#x4E00;&#x9875;</span>
</code></pre>
<ul>
<li><p><t extends="" basemodel=""> List<t> getLimitModelList(Map<string, object=""> criteria, int limitCount)</string,></t></t></p>
<ul>
<li><p>&#x67E5;&#x8BE2;&#x7B26;&#x5408;&#x6761;&#x4EF6;&#x7684;&#x6307;&#x5B9A;&#x6761;&#x6570;&#x8BB0;&#x5F55; </p>
<pre><code class="lang-java">Query query = <span class="hljs-keyword">new</span> Query(Metadata.F.type, <span class="hljs-string">&quot;GENDER&quot;</span>);
List&lt;Metadata&gt; modelList = medatadaService.getLimitModelList(query.build(), <span class="hljs-number">10</span>); <span class="hljs-comment">//&#x8FD4;&#x56DE;10&#x6761;</span>
</code></pre>
</li>
</ul>
</li>
<li><t extends="" basemodel="">T getSingleModel(Map<string, object=""> criteria)<ul>
<li>&#x67E5;&#x8BE2;&#x7B26;&#x5408;&#x6761;&#x4EF6;&#x7684;1&#x6761;&#x8BB0;&#x5F55;</li>
</ul>
</string,></t></li>
</ul>
<pre><code class="lang-java">    Query query = <span class="hljs-keyword">new</span> Query(Metadata.F.itemName, <span class="hljs-string">&quot;&#x7537;&quot;</span>);
    Metadata metadata = medatadaService.getSingleModel(query.build()); <span class="hljs-comment">//&#x8FD4;&#x56DE;10&#x6761;</span>
</code></pre>
<ul>
<li>List<map<string, object="">&gt; getMapList(Map<string, object=""> criteria, String[] loadFields, int... page);<ul>
<li>&#x6839;&#x636E;&#x6761;&#x4EF6;&#xFF0C;&#x4EE5;&#x53CA;&#x9700;&#x8981;&#x83B7;&#x53D6;&#x7684;&#x5B57;&#x6BB5;&#x6570;&#x7EC4;&#xFF0C;&#x4EE5;&#x53CA;&#x9875;&#x7801;&#xFF0C;&#x6765;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;Map&#x7C7B;&#x578B;&#x7684;&#x6570;&#x636E;&#x5217;&#x8868;&#xFF0C;&#x9002;&#x7528;&#x4E8E;&#x4EC5;&#x67E5;&#x8BE2;&#x5C11;&#x6570;&#x5217;&#x4E0D;&#x9700;&#x8981;&#x8FD4;&#x56DE;Model&#x7684;&#x573A;&#x666F;</li>
<li>loadFields&#x662F;&#x8FD4;&#x56DE;&#x5BF9;&#x8C61;&#x7684;&#x6570;&#x7EC4;&#xFF0C;&#x901A;&#x8FC7;Model&#x4E2D;F&#x9759;&#x6001;&#x7C7B;&#x6307;&#x5B9A;</li>
<li>&#x5206;&#x9875;&#x53C2;&#x6570;page&#x4E3A;&#x53D8;&#x53C2;&#xFF0C;&#x4E0D;&#x4F20;&#x8868;&#x793A;&#x83B7;&#x53D6;&#x7B26;&#x5408;&#x6761;&#x4EF6;&#x7684;&#x6240;&#x6709;&#x8BB0;&#x5F55;</li>
</ul>
</string,></map<string,></li>
</ul>
<pre><code class="lang-java">    Query query = <span class="hljs-keyword">new</span> Query();
    query.add(Metadata.F.type, <span class="hljs-string">&quot;GENDER&quot;</span>);
    query.addGT(Metadata.F.parentId, <span class="hljs-number">0</span>);
    List&lt;Map&lt;String, Object&gt;&gt; mapList = medatadaService.getMapList(query.build(), <span class="hljs-keyword">new</span> String[]{Metadata.F.id, Metadata.F.itemName, Metadata.F.itemValue});
</code></pre>
<ul>
<li>List<map<string, object="">&gt; getKeyValuePairList(Map<string, object=""> criteria, String keyField, String valueField);<ul>
<li>&#x6839;&#x636E;&#x4F20;&#x5165;&#x7684;&#x6761;&#x4EF6;&#xFF0C;&#x83B7;&#x53D6;&#x76F8;&#x5173;&#x7684;&#x952E;&#x503C;&#x5BF9;&#x5217;&#x8868;</li>
<li>&#x5E38;&#x7528;&#x4E8E;&#x5173;&#x8054;&#x5BF9;&#x8C61;&#x6570;&#x636E;&#x83B7;&#x53D6; &#x6216;&#x8005; &#x6784;&#x5EFA;&#x524D;&#x7AEF;&#x4E0B;&#x62C9;&#x6846;&#x7B49;&#x573A;&#x666F; </li>
</ul>
</string,></map<string,></li>
</ul>
<pre><code class="lang-java">    Query query = <span class="hljs-keyword">new</span> Query();
    query.add(Metadata.F.type, <span class="hljs-string">&quot;GENDER&quot;</span>);
    query.addGT(Metadata.F.parentId, <span class="hljs-number">0</span>);
    List&lt;Map&lt;String, Object&gt;&gt; mapList = medatadaService.getKeyValuePairList(query.build(), Metadata.F.itemName, Metadata.F.itemValue);
</code></pre>
<h2 id="&#x65B0;&#x5EFA;&#x4E00;&#x4E2A;crud&#x7684;service"><a name="&#x65B0;&#x5EFA;&#x4E00;&#x4E2A;crud&#x7684;service" class="anchor-navigation-ex-anchor" href="#&#x65B0;&#x5EFA;&#x4E00;&#x4E2A;crud&#x7684;service"><i class="fa fa-link" aria-hidden="true"></i></a>1.2. &#x65B0;&#x5EFA;&#x4E00;&#x4E2A;CRUD&#x7684;Service</h2>
<ol>
<li>&#x5728;&#x9879;&#x76EE;service&#x5305;&#x76EE;&#x5F55;&#x4E0B;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;service&#x63A5;&#x53E3;&#xFF0C;&#x5E76;&#x7EE7;&#x627F;&#x81EA;framework&#x4E2D;&#x7684;BaseService&#x63A5;&#x53E3;&#xFF0C;&#x4F8B;&#x5982;&#xFF1A;</li>
</ol>
<pre><code class="lang-java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">interface</span> <span class="hljs-title">MyCustomService</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">BaseService</span></span>{
}
</code></pre>
<ol>
<li>&#x521B;&#x5EFA;service&#x5B9E;&#x73B0;&#x7C7B;
&#x5728;&#x9879;&#x76EE;&#x4E2D;service/impl&#x7684;&#x5305;&#x76EE;&#x5F55;&#x4E0B;&#xFF0C;&#x5EFA;&#x4E00;&#x4E2A;service&#x5B9E;&#x73B0;&#x7C7B;&#xFF0C;&#x7EE7;&#x627F;&#x81EA;framework&#x4E2D;&#x7684;BaseServiceImpl&#x65B9;&#x6CD5;&#x5E76;&#x5B9E;&#x73B0;&#x4F60;&#x7684;service&#x63A5;&#x53E3;&#xFF0C;&#x5E76;&#x6DFB;&#x52A0;@Service&#x6CE8;&#x89E3;&#xFF0C;
&#x4F8B;&#x5982;&#xFF1A;</li>
</ol>
<pre><code class="lang-java"><span class="hljs-meta">@Service</span>
<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">MetadataServiceImpl</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">BaseServiceImpl</span> <span class="hljs-keyword">implements</span> <span class="hljs-title">MetadataService</span> </span>{
    <span class="hljs-meta">@Autowired</span>
    <span class="hljs-keyword">private</span> MetadataMapper metadataMapper;
    <span class="hljs-comment">// &#x8FD4;&#x56DE;&#x4F60;&#x7684;mapper</span>
    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">protected</span> BaseMapper <span class="hljs-title">getMapper</span><span class="hljs-params">()</span></span>{<span class="hljs-keyword">return</span> metadataMapper;}
}
</code></pre>
<p>service&#x5B9E;&#x73B0;&#x7C7B;&#x4E2D;&#x9700;&#x8981;&#x6CE8;&#x5165;&#x4F60;&#x7684;mapper&#xFF0C;&#x4EE5;&#x4FBF;&#x5BF9;&#x63A5;&#x63A5;&#x53E3;&#x7684;SQL&#x5B9E;&#x73B0;</p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                

            </div>

            
                
                <a href="Model基类.html" class="navigation navigation-prev " aria-label="Previous page: Model基类">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="Mapper基类与SQL.html" class="navigation navigation-next " aria-label="Next page: Mapper基类与SQL">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"Service基类","level":"1.3.2","depth":2,"next":{"title":"Mapper基类与SQL","level":"1.3.3","depth":2,"path":"CRUD通用封装/Mapper基类与SQL.md","ref":"CRUD通用封装/Mapper基类与SQL.md","articles":[]},"previous":{"title":"Model基类","level":"1.3.1","depth":2,"path":"CRUD通用封装/Model基类.md","ref":"CRUD通用封装/Model基类.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-sharing","sharing-plus","anchor-navigation-ex","theme-vuejs-2"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"search":{},"sharing-plus":{"qq":false,"all":["facebook","google","twitter","instapaper","linkedin","pocket","stumbleupon"],"douban":false,"facebook":true,"weibo":false,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":true,"messenger":false,"line":false,"vk":false,"pocket":true,"google":false,"viber":false,"stumbleupon":false,"qzone":false,"linkedin":false},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"theme-vuejs-2":{},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"anchor-navigation-ex":{"mode":"float","pageTop":{"level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"showLevel":true,"tocLevel1Icon":"fa fa-hand-o-right","tocLevel2Icon":"fa fa-hand-o-right","tocLevel3Icon":"fa fa-hand-o-right","showGoTop":true,"isShowTocTitleIcon":true,"printLog":false,"multipleH1":true,"associatedWithSummary":true,"float":{"floatIcon":"fa fa-navicon","level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false}},"sharing":{"qq":true,"all":["weibo","qq","linkedin","qzone","douban"],"douban":false,"weibo":true,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":false,"messenger":false,"line":false,"vk":false,"pocket":false,"viber":false,"stumbleupon":false,"qzone":true,"linkedin":false},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"Diboot基础框架","gitbook":"*","description":"Diboot基础框架"},"file":{"path":"CRUD通用封装/Service基类.md","mtime":"2018-11-08T08:51:40.454Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-11-10T15:08:25.671Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-sharing-plus/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

